
var config = $.extend(true, {}, listApp, {
    data : {
        service : spotService,
        treeData:{},
        treeChildren:[],
        searchVm:{
            name:'',
            parentId:'',
            spotIds:[],
        },
        tableVm:{
            loading:false
        },
        editVm:{
            editFormRules:{
                formRules:{
                    name : [ {required : true,message : '请输入站点名称',trigger : 'change'} ],
                    // parentId : [ {required : true,message : '请输入上级站点',trigger : 'change'} ]
                }
            }
        },
        treeStyle:{
            float:'left',
            width:'20%'
        },
        tableStyle:{
            float:'left',
            marginLeft:'20px',
            width:'78%'
        },
        spotList:[],
        requestPagePath:'requestPageList'
    },
    methods : {
        getTreeSelectedVal:function (data) {
            this.treeData = data;
            this.searchVm.parentId=data.id;
            this.searchVm.spotIds=this.treeChildren;
            this.searchVm.loadChildren=1;
            this.search();
        },
        collapse:function (isCollapsed) {
            if(isCollapsed){
                this.treeStyle.width='3%';
                this.tableStyle.width='80%';
            }else{
                this.treeStyle.width='20%';
                this.tableStyle.width='78%';
            }
        },
        getSpotList:function (spotId) {
            console.log('getSpotList spotId',spotId);
            var param={
                curSpotId:spotId
            }
            var _this=this;
            //加载spotList列表
            spotService.getAllSpot("/getAllSpot",param,{
                success : function(ret) {
                    _this.spotList=ret;

                    if(_this.treeData!=undefined && _this.treeData.id!=undefined &&
                        !_this.treeData.isDevice && _this.editVm.isAdd && _this.editVm.visible){
                        _this.$set(_this.editVm.data,"parentId",_this.treeData.id);
                    }
                },
                fail : function(res) {
                    _this.showFailMsg(res.msg);
                }
            })
            if(this.$refs['editForm']!=null && this.$refs['editForm']!=undefined)
                this.$refs['editForm'].resetFields();


        },
        getTreeChildren:function (data) {
            var _this=this;
            _this.treeChildren=[];
            if(data!=null && data!=undefined && data.length>0){
                data.forEach(function(item,index,array){
                    //执行代码
                    _this.treeChildren.push(item.id);
                })
                console.log(_this.treeChildren)
            }

        }



    }
});
var app = new Vue(config);